﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="ContratoRefeicaoDetalhe.aspx.cs" Inherits="welwitschia.Contratos.ContratoRefeicaoDetalhe" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <script type="text/javascript" language="javascript">
        $(function () {
            $("#tabs").tabs();
        });
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
 <fieldset>
        <asp:HiddenField ID="hfIdRefeicaoContratada" runat ="Server" />
        <legend>Informação de Refeição Contrato</legend>
        <p>
            <asp:Label ID="lblContrato" runat="server" Text="Contrato:" />
            <asp:TextBox runat="server" ID="txtNumeroContrato" />
            <asp:TextBox runat="server" ID="txtDataContrato" />
        </p>
        <p>
            <asp:Label ID="lblCliente" runat="server" Text="Cliente:" />
            <asp:TextBox runat="server" ID="txtIdCliente" />
            <asp:TextBox runat="server" ID="txtNomeCliente" />
        </p>
        <p>
            <asp:Label ID="lblUnidade" runat="server" Text="Unidade:" />
            <asp:TextBox runat="server" ID="txtIdUnidade" />
            <asp:TextBox runat="server" ID="txtDesignacao" />
        </p>
        <p>
            <asp:Label ID="lblTipoRefeicao" runat="server" Text="Tipo Refeição:" />
            <asp:DropDownList ID="ddlTipoRefeicao" runat="server"></asp:DropDownList>
        </p>
        <p>
            <asp:Label ID="lblClasseRefeicao" runat="server" Text="Classe Refeição:" />
            <asp:DropDownList ID="ddlClasseRefeicao" runat="server"></asp:DropDownList>
        </p>
        </fieldset>

        <div id="tabs">
        <ul>
            <li><a href="#tabs-1">Opções</a></li>
            <li><a href="#tabs-2">Preços</a></li>
            <li><a href="#tabs-3">Unidades</a></li>
        </ul>
        <div id="tabs-1">
            <asp:ListView runat="server" ID="lvOpcoes" OnItemDeleting="lvOpcoes_ItemDeleting"
                OnItemEditing="lvOpcoes_ItemEditing" OnItemCommand="lvOpcoes_ItemCommand">
                <LayoutTemplate>
                     <table runat="server" class="grd" id="table1">
                        <thead>
                            <tr class="ghdr">
                                <td>
                                    <asp:Label ID="Label2" runat="server">Tipo Opção</asp:Label>
                                </td>
                                <td>
                                    <asp:Label ID="Label3" runat="server">Descrição</asp:Label>
                                </td>
                                <td>
                                    <asp:Label ID="Label5" runat="server">&nbsp;</asp:Label>
                                </td>
                            </tr>
                        </thead>
                        <tr runat="server" id="itemPlaceholder">
                        </tr>
                    </table>
                </LayoutTemplate>
                <ItemTemplate>
                    <tr id="Tr1" runat="server">
                        <td id="Td1" runat="server">
                            <%-- Data-bound content. --%>
                            <asp:Label ID="lblUnidade" runat="server" Text='<%#Eval("TipoOpcao.Descricao") %>' />
                        </td>
                        <td id="Td2" runat="server">
                            <%-- Data-bound content. --%>
                            <asp:Label ID="lblDesignacao" runat="server" Text='<%#Eval("Descricao") %>' />
                        </td>
                        <td id="Td3" runat="server">
                            <%-- Data-bound content. --%>
                            <asp:LinkButton ID="EditButton" CommandName="Edit" CommandArgument='<%# String.Concat(Eval("RefeicaoContratada.IdRefeicaoContratada"),";",Eval("TipoOpcao.Codigo"))%>'
                                runat="server" Text="Editar"></asp:LinkButton>
                            <asp:LinkButton ID="DeleteButton" OnClientClick="return confirm('Apaga registo?');"
                                CommandName="Delete" CommandArgument='<%# String.Concat(Eval("RefeicaoContratada.IdRefeicaoContratada"),";",Eval("TipoOpcao.Codigo"))%>' runat="server"
                                Text="Apagar"></asp:LinkButton>
                        </td>
                    </tr>
                </ItemTemplate>
            </asp:ListView>
        </div>
        <div id="tabs-2">
            <asp:ListView runat="server" ID="lvPrecos" OnItemDeleting="lvPrecos_ItemDeleting"
                OnItemEditing="lvPrecos_ItemEditing" OnItemCommand="lvPrecos_ItemCommand">
                <LayoutTemplate>
                     <table runat="server" class="grd" id="table1">
                        <thead>
                            <tr class="ghdr">
                                <td>
                                    <asp:Label ID="Label2" runat="server">Tipo Serviço</asp:Label>
                                </td>
                                <td>
                                    <asp:Label ID="Label3" runat="server">Preço</asp:Label>
                                </td>
                                <td>
                                    <asp:Label ID="Label5" runat="server">&nbsp;</asp:Label>
                                </td>
                            </tr>
                        </thead>
                        <tr runat="server" id="itemPlaceholder">
                        </tr>
                    </table>
                </LayoutTemplate>
                <ItemTemplate>
                    <tr id="Tr1" runat="server">
                        <td id="Td1" runat="server">
                            <%-- Data-bound content. --%>
                            <asp:Label ID="lblUnidade" runat="server" Text='<%#Eval("TipoServico.Descricao") %>' />
                        </td>
                        <td id="Td2" runat="server">
                            <%-- Data-bound content. --%>
                            <asp:Label ID="lblDesignacao" runat="server" Text='<%#Eval("Preco") %>' />
                        </td>
                        <td id="Td3" runat="server">
                            <%-- Data-bound content. --%>
                            <asp:LinkButton ID="EditButton" CommandName="Edit" CommandArgument='<%# String.Concat(Eval("RefeicaoContratada.IdRefeicaoContratada"),";",Eval("TipoServico.Codigo"))%>'
                                runat="server" Text="Editar"></asp:LinkButton>
                            <asp:LinkButton ID="DeleteButton" OnClientClick="return confirm('Apaga registo?');"
                                CommandName="Delete" CommandArgument='<%# String.Concat(Eval("RefeicaoContratada.IdRefeicaoContratada"),";",Eval("TipoServico.Codigo"))%>' runat="server"
                                Text="Apagar"></asp:LinkButton>
                        </td>
                    </tr>
                </ItemTemplate>
            </asp:ListView>
        </div>
         <div id="tabs-3">
           <asp:ListView runat="server" ID="lvUnidades" OnItemDeleting="lvUnidades_ItemDeleting"
                OnItemEditing="lvUnidades_ItemEditing" 
                OnItemCommand="lvUnidades_ItemCommand" ondatabinding="lvUnidades_DataBinding" 
                onitemcreated="lvUnidades_ItemCreated" 
                onitemdatabound="lvUnidades_ItemDataBound">
                <LayoutTemplate>
                   <table runat="server" class="grd" id="table1">
                        <thead>
                            <tr class="ghdr">
                                <td>
                                    <asp:Label ID="Label2" runat="server">Servida</asp:Label>
                                </td>
                                <td>
                                    <asp:Label ID="Label3" runat="server">Unidade</asp:Label>
                                </td>
                                <td>
                                    <asp:Label ID="Label5" runat="server">Tipo Serviço</asp:Label>
                                </td>
                            </tr>
                        </thead>
                        <tr runat="server" id="itemPlaceholder">
                        </tr>
                    </table>
                </LayoutTemplate>
                <ItemTemplate>
                    <tr id="Tr1" runat="server">
                        <td id="Td1" runat="server">
                            <%-- Data-bound content. --%>
                            <asp:HiddenField ID="hfActivaEstadoOriginal" runat="Server" Value='<%#Eval("Activa")%>'/>
                            <asp:CheckBox ID="chkServicoActivo" runat="server"  Checked='<%#Eval("Activa")%>' />
                        </td>
                        <td id="Td2" runat="server">
                            <%-- Data-bound content. --%>
                             <asp:HiddenField ID="hfIdUnidade" runat="Server" Value='<%#Eval("Unidade.IdUnidade")%>'/>
                            <asp:Label ID="lblTipoRefeicao" runat="server" Text='<%#Eval("Unidade.Designacao")%>' />
                        </td>
                        <td id="Td4" runat="server">
                            <%-- Data-bound content. --%>
                            <asp:HiddenField ID="hfCodTipoServico" runat="Server" Value='<%#Eval("TipoServico.Codigo")%>'/>
                            <asp:DropDownList ID="ddlTipoServico"  runat="server" />
                        </td>
                    </tr>
                </ItemTemplate>
            </asp:ListView>
        </div>
    </div>

    <asp:Button ID="btnAdOpcao" runat="server" Text="Adicionar Opção" 
        onclick="btnAdOpcao_Click" />
    <asp:Button ID="btnAdPreco" runat="server" Text="Adicionar Preço" 
        onclick="btnAdPreco_Click" />
    <asp:Button ID="btnGravar" runat="server" Text="Gravar" OnClick="btnGravar_Click" />
    <asp:Button ID="btnVoltar" runat="server" Text="Voltar" 
        onclick="btnVoltar_Click" />
</asp:Content>
